package com.bookcloud.java21.chapter5.递归过程55;

public class RecursionExamples {

  // 阶乘的递归调用过程 4 = 4*3*2*1
  public static int factorial(int n) {
    if (n == 1) {
      return 1;
    } else {
      return n * factorial(n - 1);
    }
  }

  public static void main(String[] args) {
    int n = 5;
    // 5*4*3*2*1
    int result = factorial(n);
    System.out.println("阶乘的结果为:" + result);
  }
}
